<?php
class Admin_Form_AddRegionArticle extends Admin_Form_AddArticle {
	public function init() {
		$dataMaper 	= new M_Tool_DataMapper();
		$tbCountry = new M_DbTable_Country();
		$listCountry = $tbCountry->getListOther(M_DbTable_Country::DEFAULT_VIETNAM_COUNTRY_ID)->query()->fetchAll();

		$title 	 = new Zend_Form_Element_Text('title');
		$enTitle = new Zend_Form_Element_Text('en_title');

		$tbcountry = new M_DbTable_Country();
		$country   = new Zend_Form_Element_Select(
				'country',
                 array('label'        => 'Country',
                 	   'RegisterInArrayValidator' => false,
                       'attribs'      => array('class'                     => 'chainselect input-medium',
						                       'data-chainselect-source'   => '/admin/index/ajax?ajax=list-region',
						                       'data-chainselect-target'   => '[data-chainselect-selector=\'region-1\']'),
						                       'multiOptions' => $dataMaper->mapKeyValue(
							                       $listCountry,
							                       'id',
							                       'en_name',
							                       array('' => 'Country')
						                       )
                        ));

		$region   = new Zend_Form_Element_Select(
				'reference_id',
				array(
						'label'    => 'City - province',
                 	    'required'	 => true,
						'RegisterInArrayValidator' => false,
						'attribs'  => array(
								'class'	                    => 'input-medium',
								'data-chainselect-selector' => 'region-1',
						),
						'multiOptions' => ($this->_request->getActionName() == 'edit')
										  ? $dataMaper->mapKeyValue(
							                       new M_DbTable_Region(),
							                       'id',
							                       'en_name')
										  : array('' => 'City - province')
				));

		$description = new Zend_Form_Element_Textarea(
				'description',
				array('label' 		=> 'Description'));

		$thumbnail = new Zend_Form_Element_File(
				'thumbnail',
				array('label' => 'Thumbnail'));

		$type = array(
		        M_DbTable_Article::REGION_ARTICLE_TYPE_TRAVEL_DESTINATION  => 'Travel Destination'
		        );

		$type 	  = new Zend_Form_Element_Select(
		        'type',
		        array('label'		 => 'Type',
	                  'multiOptions' => $type));

		$this->addElement($enTitle)
			 ->addElement($title)
			 ->addElement($country)
			 ->addElement($region)
			 ->addElement($type)
			 ->addElement($thumbnail);

		parent::init();

		$this->setLegend('Add new article about region');
		$this->addActionGroup()
			 ->makeup();
	}
}